package test;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;

public class DataHandle {

	/**
	 * @param args
	 * @throws Exception 
	 * @throws UnsupportedEncodingException 
	 */
	public static void main(String[] args) throws UnsupportedEncodingException, Exception {
		File f = new File("d:\\tmp\\nohup.out");
		BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(f),"utf-8"));
		
		File outFile = new File("d:/tmp/out2.csv");
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile),"utf-8"));
		
		String s = br.readLine();
		
		int x = 0;
		int totalRow = 0;
		while(s != null ) {
			if(s.indexOf("每笔")>0 ) {
				totalRow++;
				int index = s.lastIndexOf("：");
				if (index == -1) {
					index = s.lastIndexOf(":");
				}
				
				if(s.indexOf("每笔省份证号")>0){
					bw.write(s.substring(index+1) + ",");
				} else if (s.indexOf("每笔查找人行数据") > 0) {
					bw.write(s.substring(index+1) + ",");
				} else if (s.indexOf("每笔组装xml") > 0) {
					bw.write(s.substring(index+1) + ",");
				} else if (s.indexOf("每笔调用规则") > 0) {
					bw.write(s.substring(index+1) + ",");
				} else if (s.indexOf("每笔解析xml") > 0) {
					bw.write(s.substring(index+1) + ",");
				} else if (s.indexOf("每笔总耗时") > 0) {
					bw.write(s.substring(index+1) + ",");
				} else {
					bw.write(" ,");
				}
				
				if (index > 0) {
					
					//System.out.print(s.substring(index+1) + ",");
					//bw.write(s.substring(index+1) + ",");
						x++;
						if (x == 6) {
							//System.out.println();
							bw.write("\n");
							x = 0;
						} 
				}
			}
			
			s=br.readLine();
		}
		bw.flush();
		br.close();
		bw.close();

		System.out.println(totalRow);
	}

}
